﻿<UserControl x:Class="LINQPad.OpenAccess.UI.View.PredefinedConnectionSettingsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:conv="clr-namespace:LINQPad.OpenAccess.UI.Converters"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             MinHeight="41" MinWidth="250"
             mc:Ignorable="d" d:DesignWidth="396" Height="266">
    <UserControl.Resources>
        <conv:NegatedBooleanToVisibilityConverter x:Key="NegatedBool2Vis" />
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Grid.Column="0" Text="connection name:" />
        <TextBlock Grid.Row="0" Grid.Column="1" Text="(app.config required)" />
        <Button Grid.Row="0" Grid.Column="2"
                Command="{Binding RefreshCommand}" Margin="2 1">
            <Image Source="../Images/Refresh.png" Height="12" Width="12" />
        </Button>
        <TextBlock Grid.Row="0" Grid.Column="1" Text="(app.config required)" />
        <ComboBox Grid.Row="1" Grid.ColumnSpan="3" Margin="5 0" 
                  VerticalAlignment="Top" HorizontalAlignment="Stretch"
                  ItemsSource="{Binding PredefinedConnections}"
                  DisplayMemberPath="Name"
                  SelectedItem="{Binding PredefinedConnection,Mode=TwoWay, ValidatesOnDataErrors=True}">
        </ComboBox>
        <TextBlock Grid.Row="1" Grid.ColumnSpan="3" Style="{DynamicResource ErrorHintTextBlockStyle}" 
                   Margin="10 2" Visibility="{Binding HasPredefinedConnections, Converter={StaticResource NegatedBool2Vis}, ValidatesOnDataErrors=True}"
                   Text="no connections available..." />
        <TextBlock Grid.Row="2" Grid.ColumnSpan="3"  
                   Text="connection string:" />
        <TextBox Grid.Row="3" Grid.ColumnSpan="3" Margin="5 0" Style="{DynamicResource ReadOnlyMultiLineTextBoxStyle}" 
                 MinLines="5" MaxLines="8"
                 Text="{Binding PredefinedConnection.ConnectionString, Mode=OneWay, FallbackValue='no connection selected...', ValidatesOnDataErrors=True}"  />
        <TextBlock Grid.Row="4" Grid.ColumnSpan="3"  
                   Text="provider name:" />
        <TextBox Grid.Row="5" Grid.ColumnSpan="3" Margin="5 0" Style="{DynamicResource ReadOnlyTextBoxStyle}"
                 Text="{Binding PredefinedConnection.ProviderName, Mode=OneWay}"  />
    </Grid>
</UserControl>
